import request from '@/utils/request'

export function login(data) {
  return new Promise(resolve => {
    resolve(request({
      url: '/user/login',
      method: 'post',
      data
    }))
  })
}

export function register(data) {
  return new Promise(resolve => {
    resolve(request({
      url: '/user/register',
      method: 'post',
      data
    }))
  })
}

export function getInfo(token) {
  return new Promise(resolve => {
    resolve(request({
      url: '/user/infoById',
      method: 'get',
      params: {
        'id': token
      }
    }))
  })
}

export function updateUserProfile(data) {
  return new Promise(resolve => {
    resolve(request({
      url: '/user/updateInfo',
      method: 'put',
      data: data
    }))
  })
}

export function uploadAvatar(data) {
  return new Promise(resolve => {
    resolve(request({
      url: '/user/uploadAvatar',
      method: 'post',
      data: data
    }))
  })
}

export function getUserList(data) {
  return new Promise(resolve => {
    resolve(request({
      url: '/user/getUserList',
      method: 'get'
    }))
  })
}

export function deleteUser(id) {
  return new Promise(resolve => {
    resolve(request({
      url: '/user/delete',
      method: 'get',
      params: {
        id: id
      }
    }))
  })
}
